<template>
  <HomePanel ref="target" title="人气推荐" sub-title="人气爆棚 不容错过">
    <Transition name="fade">
      <ul v-if="list.length" ref="pannel" class="goods-list">
        <li v-for="item in list" :key="item.id">
          <RouterLink to="/"> <img :src="item.picture" alt="" /></RouterLink>
          <p class="name">{{ item.title }}</p>
          <p class="desc">{{ item.alt }}</p>
        </li>
      </ul>
      <HomeSkeleton v-else />
    </Transition>
  </HomePanel>
</template>

<script>
import HomeSkeleton from './home-skeleton'
import { findHot } from '@/api/home'
import HomePanel from './home-panel.vue'
import { useLazyData } from '@/hooks'
export default {
  name: 'HomeHot',
  components: { HomePanel, HomeSkeleton },
  setup() {
    // const list = ref([])
    // findHot().then(({ result }) => {
    //   list.value = result
    // })
    const { target, list } = useLazyData(findHot)
    return { list, target }
  }
}
</script>

<style lang="less" scoped>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>
